package com.seveneight.baijiesteward.ui.main.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.seveneight.baijiesteward.R;
import com.seveneight.baijiesteward.base.BaseActivity;
import com.seveneight.baijiesteward.bean.AnyBean;
import com.seveneight.baijiesteward.http.MyCallBack;
import com.seveneight.baijiesteward.ui.user.model.BankCatdApplyModel;
import com.seveneight.baijiesteward.ui.user.model.BankCatdInfoModel;
import com.seveneight.baijiesteward.utils.WindowUtil;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 *卡面详情
 */
public class BankCardInfoActivity extends BaseActivity implements View.OnClickListener{

    @BindView(R.id.tv_title)
    TextView tv_title;
    @BindView(R.id.bank_card_name)
    TextView bank_card_name;
    @BindView(R.id.bank_card_name2)
    TextView bank_card_name2;
    @BindView(R.id.description)
    TextView description;
    @BindView(R.id.item_bank_photo)
    ImageView item_bank_photo;
    public String StationChannelId;
    public String StationBankCardChannelId;
    BankCatdInfoModel model;
    BankCatdApplyModel submitApi;

    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_bank_card_info);
    }

    @Override
    protected void initView() {
        tv_title.setText("卡面详情");
        StationChannelId=getIntent().getStringExtra("StationChannelId");
        StationBankCardChannelId=getIntent().getStringExtra("StationBankCardChannelId");

    }

    @Override
    protected void initData() {
        submitApi=new BankCatdApplyModel();
        Map<String,String> params=new HashMap<>();
        params.put("StationChannelId",StationChannelId);
        params.put("StationBankCardChannelId",StationBankCardChannelId);
        model=new BankCatdInfoModel();
        model.getBankList(this, jsonFormat.AddCard(params), new MyCallBack<AnyBean>() {
            @Override
            public void onSuccess(AnyBean anyBean) {
                Glide.with(getContext()).load(anyBean.getImgUrlPath()).into(item_bank_photo);
                bank_card_name.setText(anyBean.getName());
                bank_card_name2.setText(anyBean.getName());
                description.setText(anyBean.getDescription());
            }

            @Override
            public void onFailed() {

            }
        });


    }

    @Override
    protected void setListener() {

    }

    @OnClick({R.id.iv_back,R.id.bt_submit,R.id.charges,R.id.bank_more})
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.iv_back:
                finish();
                break;
            case R.id.bt_submit:///确定申请
                submitData();
                break;
            case R.id.charges://收费标准

                break;
            case R.id.bank_more://更多

                break;
        }

    }
    public void submitData(){
        Map<String,String> params=new HashMap<>();
        params.put("Name",userBean.getRankName());
        params.put("Mobile",userBean.getMobilePhone());
        params.put("IdCard",userBean.getIdCardNo());
        params.put("StationChannelId",StationChannelId);
        params.put("StationBankCardChannelId",StationBankCardChannelId);

        submitApi.getBankList(this, jsonFormat.AddCard(params), new MyCallBack<AnyBean>() {
            @Override
            public void onSuccess(AnyBean anyBean) {
                setResult(RESULT_OK);
                Bundle bundle = new Bundle();
                bundle.putString("url", anyBean.getUrl());
                WindowUtil.getInstance().startActivity(getContext(), WebActivity.class, bundle);
                finish();
            }

            @Override
            public void onFailed() {

            }
        });
    }
}
